<div class="layui-card-body" id="alert_form">
    <form class="layui-form" action="" lay-filter="alert">
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red;">*</span>用户角色</label>
            <div class="layui-input-inline">
                <select name="role_id" lay-verify="required" lay-search>
                    {volist name="roleList" id="vo"}
                    <option value="{$vo.id}" {if condition="$data and ($data.role_id eq $vo.id)"} selected{/if} >{$vo.role_name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red;">*</span>账号</label>
            <div class="layui-input-block">
                <input type="text" name="user_name" value="{$data.user_name|default=''}" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red;">*</span>密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red;">*</span>用户昵称</label>
            <div class="layui-input-block">
                <input type="text" name="nickname" value="{$data.nickname|default=''}" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="checkbox" {if condition="$data.status eq 0"}checked{/if} name="status" lay-skin="switch" lay-text="正常|禁用">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="save">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    //监听提交
    form.on('submit(save)', function (obj) {
        var post = obj.field;
        post.status = post.status == "on" ? 0 : 1;
        post.id = "{$data.id|default=''}";
        submitPost('{:url("admin/user/edit")}', post);
        return false;
    });
</script>
